package cn.kgc83.shengyin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
//import org.springframework.security.access.prepost.PreAuthorize;
import cn.kgc83.shengyin.domain.Surveyques;
import cn.kgc83.shengyin.service.ISurveyquesService;
import cn.kgc83.shengyin.vo.Page;
import cn.kgc83.shengyin.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//import com.ruoyi.common.annotation.Log;
//import com.ruoyi.common.core.controller.BaseController;
//import com.ruoyi.common.core.domain.Result;
//import com.ruoyi.common.enums.BusinessType;
//import com.ruoyi.shengyin.domain.Surveyques;
//import com.ruoyi.shengyin.service.ISurveyquesService;
//import com.ruoyi.common.utils.poi.ExcelUtil;
//import com.ruoyi.common.core.page.TableDataInfo;
//
/**
 * 调查问卷题目Controller
 * 
 * @author ruoyi
 * @date 2023-08-01
 */
@RestController
@RequestMapping("/surveyques")
public class SurveyquesController extends BaseController
{
    @Autowired
    private ISurveyquesService surveyquesService;

    /**
     * 查询调查问卷题目列表
     */
    //@PreAuthorize("@ss.hasPermi('shengyin:surveyques:list')")
    @GetMapping("/list")
    public Page<Surveyques> list(Surveyques surveyques)
    {
        startPage();
        List<Surveyques> list = surveyquesService.selectSurveyquesList(surveyques);
        return getDataTable(list);
    }

    /**
     * 导出调查问卷题目列表
     */
    //@PreAuthorize("@ss.hasPermi('shengyin:surveyques:export')")
    //@Log(title = "调查问卷题目", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, Surveyques surveyques)
//    {
//        List<Surveyques> list = surveyquesService.selectSurveyquesList(surveyques);
//        ExcelUtil<Surveyques> util = new ExcelUtil<Surveyques>(Surveyques.class);
//        util.exportExcel(response, list, "调查问卷题目数据");
//    }

    /**
     * 获取调查问卷题目详细信息
     */
    //@PreAuthorize("@ss.hasPermi('shengyin:surveyques:query')")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(surveyquesService.selectSurveyquesById(id));
    }

    /**
     * 新增调查问卷题目
     */
    //@PreAuthorize("@ss.hasPermi('shengyin:surveyques:add')")
    //@Log(title = "调查问卷题目", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody Surveyques surveyques)
    {
        return toAjax(surveyquesService.insertSurveyques(surveyques));
    }

    /**
     * 修改调查问卷题目
     */
    //@PreAuthorize("@ss.hasPermi('shengyin:surveyques:edit')")
    //@Log(title = "调查问卷题目", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody Surveyques surveyques)
    {
        return toAjax(surveyquesService.updateSurveyques(surveyques));
    }

    /**
     * 删除调查问卷题目
     */
    //@PreAuthorize("@ss.hasPermi('shengyin:surveyques:remove')")
    //@Log(title = "调查问卷题目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(surveyquesService.deleteSurveyquesByIds(ids));
    }
}
